package cn.fresh.xuanyuan.module.infra.dal.mysql.column;

import cn.fresh.xuanyuan.framework.common.pojo.PageParam;
import cn.fresh.xuanyuan.framework.common.pojo.PageResult;
import cn.fresh.xuanyuan.framework.mybatis.core.mapper.BaseMapperX;
import cn.fresh.xuanyuan.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.fresh.xuanyuan.module.infra.controller.admin.config.vo.ConfigPageReqVO;
import cn.fresh.xuanyuan.module.infra.dal.dataobject.column.MallColumnDO;
import cn.fresh.xuanyuan.module.infra.dal.dataobject.config.ConfigDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface MallColumnMapper extends BaseMapperX<MallColumnDO> {

    default PageResult<MallColumnDO> selectPage(String name, String type, PageParam pageParam) {
        LambdaQueryWrapper<MallColumnDO> queryWrapperX = new LambdaQueryWrapper<MallColumnDO>()
                .orderByAsc(MallColumnDO::getSort);
        if(StringUtils.isNotBlank(name)) {
            queryWrapperX.like(MallColumnDO::getTitle, name.trim());
        }
        if(StringUtils.isNotBlank(type)) {
            queryWrapperX.eq(MallColumnDO::getType, type.trim());
        }
        return selectPage(pageParam, queryWrapperX);
    }
}
